#include "stone.h"

Stone::Stone()
{

}
Stone::~Stone()
{

}

QString Stone::stone_name()
{
    switch (this->stone_type) {
    case jiang:
        return "将";
        break;
    case che:
        return "车";
        break;
    case ma:
        return "马";
        break;
    case pao:
        return "炮";
        break;
    case shi:
        return "士";
        break;
    case xiang:
        return "相";
        break;
    case zu:
        return "卒";
        break;
    default:
        return "  ";
        break;
    }
}


void Stone::stone_init(int init_id)
{
    struct
    {
        int x, y;
        chess_type type;
    } board_stone[16] =
    {
        {4, 0, Stone::jiang},

        {0, 0, Stone::che},
        {8, 0, Stone::che},

        {1, 0, Stone::ma},
        {7, 0, Stone::ma},

        {1, 2, Stone::pao},
        {7, 2, Stone::pao},

        {3, 0, Stone::shi},
        {5, 0, Stone::shi},

        {2, 0, Stone::xiang},
        {6, 0, Stone::xiang},

        {0, 3, Stone::zu},
        {2, 3, Stone::zu},
        {4, 3, Stone::zu},
        {6, 3, Stone::zu},
        {8, 3, Stone::zu}
    };

    if(init_id < 16)
    {
        this->stone_x = board_stone[init_id].x;
        this->stone_y = board_stone[init_id].y;
        this->stone_type = board_stone[init_id].type;
        this->stone_side = false;

    }
    else
    {
        this->stone_x = 8 - board_stone[init_id - 16].x;
        this->stone_y = 9 - board_stone[init_id - 16].y;
        this->stone_type = board_stone[init_id - 16].type;
        this->stone_side = true;
    }
    this->stone_life = true;
}



